//
//  SectionCell.m
//  ZhiHuDaily
//
//  Created by albert on 16/8/27.
//  Copyright © 2016年 albert. All rights reserved.
//

#import "SectionCell.h"
#import "NewsListModel.h"
#import "UIImageView+WebCache.h"

@interface SectionCell ()
/** 标题 */
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

/** 日期 */
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;

/** 右侧配图 */
@property (weak, nonatomic) IBOutlet UIImageView *rightImageView;
@end

@implementation SectionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(NewsListModel *)model{
    _model = model;
    
    self.titleLabel.text = model.title;
    self.dateLabel.text = model.display_date;
    
    if (!self.model.images) return;
    
    [self.rightImageView sd_setImageWithURL:[NSURL URLWithString:self.model.images[0]] placeholderImage:[UIImage imageNamed:@"Image_Preview"]];
}

#pragma mark - 更新皮肤
- (void)changeToNightSkin{// 夜间
    self.backgroundColor = JKNightSkinColor;
    self.titleLabel.textColor = self.model.alreadyRead ? JKColor(128, 128, 128) : JKColor(186, 186, 186);
    self.dateLabel.textColor = JKColor(108, 108, 108);
}

- (void)changeToDaySkin{// 白天
    self.backgroundColor = JKGlobalBgColor;
    self.titleLabel.textColor = self.model.alreadyRead ? JKColor(96, 96, 96) : [UIColor blackColor];
    self.dateLabel.textColor = JKColor(118, 118, 118);
}
@end
